//存放用户信息
let user = localStorage.getItem('username');//通过用户名来判断是否为管理员
let userName = '';
let userType = '';
if(user){
    user = JSON.parse(userName);
    userName = user.userName;
    userType = user.userType;
}

export default {
    namespaced: true,
    state :{
        userName,
        userType,
    },
    action: {
        setUser({commit},payload){
            commit('doSetUser',payload);
        }
    },
    mutations: {
        doSetUser(state,payload){
            console.log(payload);
            state.userName = payload.userName;
            state.userType = payload.userType;
            console.log('state',state);
        }
    },
}